home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / test / m_recieve.s < prev    next >
Text File  |  1998-06-04  |  2KB  |  147 lines

  1.  
  2.         incdir    "binworld:includes/"
  3.  
  4.         include    "exec/memory.i"
  5.         include    "dos/dos.i"
  6.         include    "exec_lib.i"
  7.         include    "dos_lib.i"
  8.         
  9.         include    "devices/inputevent.i"
  10.         include    "devices/serial.i"
  11.         include    "exec/io.i"
  12.  
  13.  
  14.         section    alku,code
  15.  
  16.         move.l    execbase,exec_base
  17.  
  18.         move.l    exec_base,a6
  19.         lea    dos_name,a1
  20.         moveq.l    #39,d0
  21.         jsr    OpenLibrary(a6)
  22.         move.l    d0,dos_base
  23.         beq.w    quit
  24.  
  25.         moveq.l    #64,d0
  26.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  27.         jsr    AllocVec(a6)
  28.         move.l    d0,io_buffer
  29.         beq.w    quit
  30.  
  31.         jsr    CreateMsgPort(a6)
  32.         move.l    d0,input_message_port
  33.         beq.w    quit
  34.  
  35.         move.l    input_message_port,a0
  36.         move.l    #IOEXTSER_SIZE,d0
  37.         jsr    CreateIORequest(a6)
  38.         move.l    d0,io_request
  39.         beq.w    quit
  40.  
  41.         lea    serial_device_name,a0
  42.         move.l    io_request,a1
  43.         bset.b    #5,IO_SERFLAGS(a1)        ;shared access!
  44.         moveq.l    #0,d0
  45.         moveq.l    #0,d1
  46.         jsr    OpenDevice(a6)
  47.         tst.l    d0
  48.         bne.w    quit
  49.  
  50.         move.b    #1,serial_device_status
  51.  
  52.         move.l    io_request,a1
  53.         move.l    #1,IO_LENGTH(a1)
  54.         move.l    io_buffer,IO_DATA(a1)
  55.         move.w    #SDCMD_QUERY,IO_COMMAND(a1)
  56.         jsr    DoIO(a6)
  57.         tst.l    d0
  58.         bne.w    quit
  59.  
  60.         move.w    #40,d7
  61.  
  62.         move.l    io_request,a0
  63.         move.w    IO_STATUS(a0),d0
  64. ;        btst    #5,d0
  65. ;        bne.s    quit
  66.  
  67. jee:        move.l    exec_base,a6
  68.         move.l    io_request,a1
  69.         move.l    #1,IO_LENGTH(a1)
  70.         move.l    io_buffer,IO_DATA(a1)
  71.         move.w    #CMD_READ,IO_COMMAND(a1)
  72.         jsr    DoIO(a6)
  73.         tst.l    d0
  74.         bne.w    quit
  75.  
  76.         move.l    io_request,a1
  77.         jsr    WaitIO(a6)
  78.  
  79.         move.l    io_buffer,a0
  80.         clr.b    1(a0)
  81.  
  82.         move.l    dos_base,a6
  83.         jsr    Output(a6)
  84.         move.l    d0,d1
  85.         move.l    io_buffer,d2
  86.         moveq.l    #1,d3
  87.         jsr    Write(a6)
  88.  
  89.         dbra    d7,jee
  90.  
  91. io_connect_check_abort:
  92. quit:        move.l    exec_base,a6
  93.         move.l    io_request,d0
  94.         beq.s    no_io_request
  95.         move.l    d0,a1
  96.         jsr    _LVOAbortIO(a6)
  97.  
  98.         tst.b    serial_device_status
  99.         beq.s    no_close_device
  100.         move.l    io_request,a1
  101.         jsr    CloseDevice(a6)
  102.  
  103. no_close_device:move.l    io_request,a0
  104.         jsr    DeleteIORequest(a6)
  105.  
  106. no_io_request:    move.l    input_message_port,d0
  107.         beq.s    no_input_message_port
  108.         move.l    d0,a0
  109.         jsr    DeleteMsgPort(a6)
  110.  
  111. no_input_message_port:
  112.         move.l    io_buffer,d0
  113.         beq.s    no_io_buffer
  114.         move.l    d0,a1
  115.         jsr    FreeVec(a6)
  116.  
  117. no_io_buffer:    move.l    dos_base,d0
  118.         beq.s    no_dos_base
  119.         move.l    d0,a1
  120.         jsr    CloseLibrary(a6)
  121.  
  122. no_dos_base:    moveq.l    #0,d0
  123.         rts
  124.  
  125.  
  126.         section    loppu,data
  127.  
  128. exec_base:    dc.l    0
  129. dos_base:    dc.l    0
  130. dos_name:    dc.b    "dos.library",0
  131.         even
  132. serial_device_name:
  133.         dc.b    "8n1.device",0
  134.         even
  135.  
  136. io_request:    dc.l    0
  137. io_buffer:    dc.l    0
  138.  
  139. input_message_port:
  140.         dc.l    0
  141.  
  142. serial_device_status:
  143.         dc.b    0
  144.         even
  145.  
  146.         END
  147.